package de.matusystems.rest

import grails.converters.JSON
import groovyx.net.http.*

class EmailWebService {

	def sendEmail(String to, String subject, String message) {

		HTTPBuilder http = new HTTPBuilder(System.getenv()['CAPP_EMAIL_SERVICE']+"/send")

		def jsonResponse

		http.request(Method.POST, groovyx.net.http.ContentType.JSON) { req ->
			body = [to : to, subject : subject, message : message]
			response.success = { resp, json ->
				jsonResponse = json
			}
		}

		return jsonResponse as JSON
	}
}
